// import { defineStore } from "pinia";
import { defineStore } from "../pinia";
import { computed, ref } from "vue";

export const useTodoList1 = defineStore('todoList1', () => {

    const todoList = ref([])
    const count = computed(() => todoList.value.length)
    const addTodo = (todo) => {
        todoList.value.push(todo)
    }
    const toggleTodo = (id) => {
        todoList.value.forEach((item) => item.completed = item.id === id)
    }
    const removeTodo = (id) => {
        todoList.value = todoList.value.filter((item) => item.id !== id)
    }
    return {
        count,
        todoList,
        addTodo,
        toggleTodo,
        removeTodo
    }
})